home *** CD-ROM | disk | FTP | other *** search
- /* Window.c */
- /* File contains functions for controlling the program including the
- main program loop */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <clib/asl_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <graphics/gfxmacros.h>
- #include <graphics/GfxBase.h>
- #include <intuition/intuition.h>
- #include <intuition/IntuitionBase.h>
- #include <libraries/asl.h>
- #include <libraries/dos.h>
- #include <libraries/gadtools.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
-
- #include "Search.c"
-
- struct TagItem frtags[] =
- {
- ASLFR_TitleText, (ULONG)"CycleDataBase File Requester",
- ASLFR_InitialHeight, MYHEIGHT,
- ASLFR_InitialWidth, MYWIDTH,
- ASLFR_InitialLeftEdge, MYLEFTEDGE,
- ASLFR_InitialTopEdge, MYTOPEDGE,
- ASLFR_PositiveText, (ULONG)"Okay",
- ASLFR_NegativeText, (ULONG)"Cancel",
- ASLFR_InitialFile, (ULONG)".cdb",
- TAG_DONE
- };
-
- /*
- ** Function for loading the database from a file.
- */
- // Removed for copyright reasons
-
- /*
- ** Function for saving the database to a file.
- */
- // Removed for copyright reasons
-
- /*
- ** Function for defining and displaying About Alert message.
- */
- void about_alert()
- {
- char message[160];
-
- strcpy(message, " Cycle Database program created by Donald W Millican.");
- strcat(message,
- " (C) Copyright 1999 DWM Productions.");
- strcat(message,
- " Version 1.95 26/09/99. Press Left Mouse Button to continue.");
-
- message[0]=0; /* X position of the first string */
- message[1]=32; /* - " - */
- message[2]=16; /* Y - " - */
-
- message[55]='\0'; /* NULL sign which finish of the first string. */
- message[56]=TRUE; /* Continuation byte set to TRUE (new string). */
-
- message[57]=0;
- message[58]=32;
- message[59]=32;
-
- message[95]='\0';
- message[96]=TRUE;
-
- message[97]=0; /* X position of the third string. */
- message[98]=32; /* - " - */
- message[99]=48; /* Y - " - */
-
- message[158]='\0'; /* NULL sign which finish of the third string. */
- message[159]=FALSE; /* Continuation byte set to FALSE (last string). */
-
- /* We will now display the Alert message: */
- DisplayAlert( RECOVERY_ALERT, message, 64 );
- }
-
- /*
- ** Standard message handling loop with GadTools message handling functions
- ** used (GT_GetIMsg() and GT_ReplyIMsg()).
- */
- void process_window_events(struct Screen *mysc, struct Window *mywin,
- struct Gadget *my_gads[], struct Menu *mainmenustrip, struct StringInfo *gad_ptr[])
- {
- struct IntuiMessage *imsg;
- ULONG imsgClass;
- UWORD imsgCode;
- BOOL terminated = FALSE;
- struct Gadget *gad;
- UWORD menu_number, which_menu, which_item;
- MenuItem *item;
- BOOL cont = FALSE;
- BOOL move_record = FALSE;
- BOOL destdate = FALSE;
- UBYTE *data_entered;
- char sentence[DESTLENGTH];
- char datetemp[DATELENGTH];
- // char desttemp[DESTLENGTH];
- int index = 0, count, direction = 0;
- // int count2, count3;
- char space[DESTLENGTH], space2[DATELENGTH];
- long take_train = 0;
- long number = 0;
- int result, answer = 0, length = 0, matchcount = 0;
- BOOL record_found = FALSE;
- int position = 0, matches = 0;
- // Pointers for Containing search
- // int start, next;
-
- data_entered = (UBYTE *)sentence;
-
- // Clear arrays used in menu item 'New'
- for(count=0; count<DESTLENGTH; count++)
- space[count] = '\0';
- for(count=0; count<DATELENGTH; count++)
- space2[count] = '\0';
-
- while (!terminated)
- {
- Wait (1 << mywin->UserPort->mp_SigBit);
-
- /* GT_GetIMsg() returns an IntuiMessage with more friendly information for
- ** complex gadget classes. Use it wherever you get IntuiMessages where
- ** using GadTools gadgets.
- */
-
- while ((!terminated) &&
- (imsg = GT_GetIMsg(mywin->UserPort)))
- {
- /* Presuming a gadget, of course, but no harm...
- ** Only dereference this value (gad) where the Class specifies
- ** that it is a gadget event.
- */
- gad = (struct Gadget *)imsg->IAddress;
-
- imsgClass = imsg->Class;
- imsgCode = imsg->Code;
- menu_number = imsg->Code;
-
- /* Use the toolkit message-replying function here... */
- GT_ReplyIMsg(imsg);
-
- switch (imsgClass)
- {
- /* --- WARNING --- WARNING --- WARNING --- WARNING --- WARNING ---
- ** GadTools puts the gadget address into IAddress of IDCMP_MOUSEMOVE
- ** messages. This is NOT true for standard Intuition messages,
- ** but is an added feature of GadTools.
- */
- case IDCMP_VANILLAKEY:
- cont = handleVanillaKey(mywin, imsgCode, my_gads, index, direction);
- if(cont == TRUE)
- {
- if(direction < 0)
- {
- // Go back one record
- if(index > 0)
- {
- index--;
- // Load new gadget values
- GT_SetGadgetAttrs(my_gads[MYGAD_RECCOUNT], mywin, NULL, GTNM_Number, index+1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DESTGAD], mywin, NULL, GTST_String, cycledata[index].destination, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DATEGAD], mywin, NULL, GTST_String, cycledata[index].date, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, cycledata[index].cycledist1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, cycledata[index].cycledist2, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, cycledata[index].cycleouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, cycledata[index].cycleoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, cycledata[index].cyclebackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, cycledata[index].cyclebackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, cycledata[index].train, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, cycledata[index].trainouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, cycledata[index].trainoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, cycledata[index].trainbackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, cycledata[index].trainbackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, cycledata[index].totalh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, cycledata[index].totalm, TAG_END);
- }
- }
- if(direction > 0)
- {
- // Go forward one record
- if(index < TRIPS-1)
- {
- index++;
- // Load new gadget values
- GT_SetGadgetAttrs(my_gads[MYGAD_RECCOUNT], mywin, NULL, GTNM_Number, index+1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DESTGAD], mywin, NULL, GTST_String, cycledata[index].destination, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DATEGAD], mywin, NULL, GTST_String, cycledata[index].date, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, cycledata[index].cycledist1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, cycledata[index].cycledist2, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, cycledata[index].cycleouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, cycledata[index].cycleoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, cycledata[index].cyclebackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, cycledata[index].cyclebackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, cycledata[index].train, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, cycledata[index].trainouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, cycledata[index].trainoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, cycledata[index].trainbackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, cycledata[index].trainbackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, cycledata[index].totalh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, cycledata[index].totalm, TAG_END);
- }
- }
- }
- break;
- case IDCMP_GADGETUP:
- move_record = handleGadgetEvent(mysc, mywin, gad, imsgCode, my_gads);
-
- if(move_record == TRUE)
- {
- if(gad->GadgetID == MYGAD_PREVIOUS)
- {
- if(index > 0)
- {
- index--;
- // Load new gadget values
- GT_SetGadgetAttrs(my_gads[MYGAD_RECCOUNT], mywin, NULL, GTNM_Number, index+1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DESTGAD], mywin, NULL, GTST_String, cycledata[index].destination, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DATEGAD], mywin, NULL, GTST_String, cycledata[index].date, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, cycledata[index].cycledist1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, cycledata[index].cycledist2, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, cycledata[index].cycleouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, cycledata[index].cycleoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, cycledata[index].cyclebackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, cycledata[index].cyclebackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, cycledata[index].train, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, cycledata[index].trainouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, cycledata[index].trainoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, cycledata[index].trainbackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, cycledata[index].trainbackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, cycledata[index].totalh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, cycledata[index].totalm, TAG_END);
- }
- }
- if(gad->GadgetID == MYGAD_NEXT)
- {
- if(index < TRIPS-1)
- {
- index++;
- // Load new gadget values
- GT_SetGadgetAttrs(my_gads[MYGAD_RECCOUNT], mywin, NULL, GTNM_Number, index+1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DESTGAD], mywin, NULL, GTST_String, cycledata[index].destination, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DATEGAD], mywin, NULL, GTST_String, cycledata[index].date, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, cycledata[index].cycledist1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, cycledata[index].cycledist2, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, cycledata[index].cycleouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, cycledata[index].cycleoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, cycledata[index].cyclebackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, cycledata[index].cyclebackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, cycledata[index].train, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, cycledata[index].trainouth, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, cycledata[index].trainoutm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, cycledata[index].trainbackh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, cycledata[index].trainbackm, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, cycledata[index].totalh, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, cycledata[index].totalm, TAG_END);
- }
- }
- }
- if(gad->GadgetID == MYGAD_DESTGAD)
- {
- // Copy text from string gadget to working variable
- strcpy(data_entered, gad_ptr[0]->Buffer);
- strcpy(cycledata[index].destination, data_entered);
- // Set changed BOOL to TRUE
- cycledata[index].changed = TRUE;
- // recs = Go through all recs and count no of TRUE's
- records.recs[0] = 0;
- for(count=0; count<TRIPS-1; count++)
- {
- if(cycledata[count].changed == TRUE)
- records.recs[0]++;
- }
- }
- if(gad->GadgetID == MYGAD_DATEGAD)
- {
- // Copy text from string gadget to working variable
- strcpy(data_entered, gad_ptr[1]->Buffer);
- strcpy(cycledata[index].date, data_entered);
- }
- if(gad->GadgetID == MYGAD_DIST1)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cycledist1 = number;
- }
- if(gad->GadgetID == MYGAD_DIST2)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cycledist2 = number;
- }
- if(gad->GadgetID == MYGAD_CYCLEOUTH)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cycleouth = number;
- }
- if(gad->GadgetID == MYGAD_CYCLEOUTM)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cycleoutm = number;
- }
- if(gad->GadgetID == MYGAD_CYCLEBACKH)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cyclebackh = number;
- }
- if(gad->GadgetID == MYGAD_CYCLEBACKM)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].cyclebackm = number;
- }
- if(gad->GadgetID == MYGAD_TRAINTICK)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, &take_train, TAG_END);
- if(take_train == 1)
- cycledata[index].train = TRUE;
- else
- cycledata[index].train = FALSE;
- }
- if(gad->GadgetID == MYGAD_TRAINOUTH)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].trainouth = number;
- }
- if(gad->GadgetID == MYGAD_TRAINOUTM)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].trainoutm = number;
- }
- if(gad->GadgetID == MYGAD_TRAINBACKH)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].trainbackh = number;
- }
- if(gad->GadgetID == MYGAD_TRAINBACKM)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].trainbackm = number;
- }
- if(gad->GadgetID == MYGAD_TOTTIMEH)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].totalh = number;
- }
- if(gad->GadgetID == MYGAD_TOTTIMEM)
- {
- GT_GetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, &number, TAG_END);
- cycledata[index].totalm = number;
- }
-
- // Redraw gadgets to show updates
- GT_BeginRefresh(mywin);
- GT_EndRefresh(mywin, TRUE);
-
- break;
- case IDCMP_MENUPICK:
- // Menu chosen
- which_menu=MENUNUM(menu_number);
- which_item=ITEMNUM(menu_number);
-
- while( menu_number != MENUNULL )
- {
- /* Get the address of the item: */
- item = (struct MenuItem *) ItemAddress( mainmenustrip, menu_number );
-
- /* Check which item was selected: */
- if( which_menu == 0 )
- {
- if( which_item == 0 )
- {
- // If no records, don't ask to overwrite them
- if(records.recs[0] > 0)
- answer = EasyRequest(NULL, &overwrite, NULL);
- else
- answer = 1;
-
- if(answer == 1)
- {
- // new selected
- index = 0;
- records.recs[0] = 0;
-
- // Clear array of records
- for(count=0; count < TRIPS-1; count++)
- {
- strcpy(cycledata[count].destination, space);
- strcpy(cycledata[count].date, space2);
-
- cycledata[count].cycledist1 = 0;
- cycledata[count].cycledist2 = 0;
- cycledata[count].cycleouth = 0;
- cycledata[count].cycleoutm = 0;
- cycledata[count].cyclebackh = 0;
- cycledata[count].cyclebackm = 0;
- cycledata[count].train = FALSE;
- cycledata[count].trainouth = 0;
- cycledata[count].trainoutm = 0;
- cycledata[count].trainbackh = 0;
- cycledata[count].trainbackm = 0;
- cycledata[count].totalh = 0;
- cycledata[count].totalm = 0;
- cycledata[count].changed = FALSE;
- }
-
- // Clear gadgets
- GT_SetGadgetAttrs(my_gads[MYGAD_RECCOUNT], mywin, NULL, GTNM_Number, 1, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DESTGAD], mywin, NULL, GTST_String, cycledata[0].destination, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DATEGAD], mywin, NULL, GTST_String, cycledata[0].date, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST1], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_DIST2], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTH], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEOUTM], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKH], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_CYCLEBACKM], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINTICK], mywin, NULL, GTCB_Checked, FALSE, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTH], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINOUTM], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKH], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TRAINBACKM], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEH], mywin, NULL, GTIN_Number, 0, TAG_END);
- GT_SetGadgetAttrs(my_gads[MYGAD_TOTTIMEM], mywin, NULL, GTIN_Number, 0, TAG_END);
- }
- }
- if( which_item == 1 )
- {
- // If no records, don't ask to overwrite them
- if(records.recs[0] > 0)
- answer = EasyRequest(NULL, &overwrite, NULL);
- else
- answer = 1;
-
- if(answer == 1)
- {
- // load selected
- result = load(mywin, my_gads);
- if(result == 0)
- {
- // Display requester - Error while loading
- EasyRequest(NULL, &loadfail, NULL);
- }
- else
- index = 0;
- }
- }
- if( which_item == 2 )
- {
- // save selected
- result = save();
- if(result == 0)
- {
- // Display Requester - Error while saving
- EasyRequest(NULL, &savefail, NULL);
- }
- }
- if( which_item == 3 )
- {
- // about selected
- about_alert();
- }
- if( which_item == 4 )
- {
- terminated = TRUE;
- }
- }
- // Search menu
- if( which_menu == 1 )
- {
- if( which_item == 0 )
- {
- // Create & open input window
-
- // Code removed for copyright reasons
- }
- if( which_item == 1 )
- {
- // Display requester
- EasyRequest(NULL, ¬inuse, NULL);
- }
- }
-
- /* Get the following item's menu number: */
- menu_number = item->NextSelect;
- }
- break;
- case IDCMP_CLOSEWINDOW:
- terminated = TRUE;
- break;
- case IDCMP_REFRESHWINDOW:
- /* With GadTools, the application must use GT_BeginRefresh()
- ** where it would normally have used BeginRefresh()
- */
- GT_BeginRefresh(mywin);
- GT_EndRefresh(mywin, TRUE);
- break;
- }
- }
- }
- }
-
-